package com.tomvian.tools 
{
	import fl.motion.AdjustColor;
	import fl.motion.ColorMatrix;
	import flash.filters.BlurFilter;
	import flash.filters.ColorMatrixFilter;
	
	/**
	 * FilterTools
	 * @author Tom Vian
	 */
	public class FilterTools
	{
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		public static const greyscale:ColorMatrixFilter = getGreyscale();
		
		public static const blurLow4:BlurFilter = new BlurFilter(4, 4, 1);
		public static const blurLow8:BlurFilter = new BlurFilter(8, 8, 1);
		public static const blurLow16:BlurFilter = new BlurFilter(16, 16, 1);
		
		//--------------------------------------------------------------------------
		//
		//  Getters / Setters
		//
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		
		public function FilterTools() 
		{
			
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		private static function getGreyscale():ColorMatrixFilter
		{
			var b:Number = 1 / 3;
			var c:Number = 1 - (b * 2);
			var mtx:Array = [	c, b, b, 0, 0,
								b, c, b, 0, 0,
								b, b, c, 0, 0,
								0, 0, 0, 1, 0];
			return new ColorMatrixFilter(mtx);
		}
		
		public static function adjustColorFilter(brightness:Number = 0, contrast:Number = 0, saturation:Number = 0, hue:Number = 0):ColorMatrixFilter
		{
			var colour:AdjustColor = new AdjustColor;
			colour.brightness = brightness;
			colour.contrast = contrast;
			colour.saturation = saturation;
			colour.hue = hue;
			
			return new ColorMatrixFilter(colour.CalculateFinalFlatArray());
		}
	}
}